home *** CD-ROM | disk | FTP | other *** search
/ Complete Internet Archive / Complete Internet Archive.iso / Web Boards / WebForum_tar(2).Z / WebForum_tar(2) / WebForum / src / subject.pl < prev    next >
Encoding:
Text File  |  1995-01-19  |  4.6 KB  |  149 lines

  1. # subject-level access: show all the messages associated
  2. #                       with a particular subject.
  3. #                       and display one
  4. # Copyright (C) 1994 Afzal Ballim
  5.  
  6. ############################################################
  7. #
  8. # WFCommandSubject: display all the messages of a subject
  9. #
  10. sub WFCommandSubject {
  11.  local ($direction,%in)=@_;
  12.  local ($message,$forum,$subject,$thelist,@messages,
  13.         $forumdec,$subjectdec,$thedir,@tmp,$mform,
  14.         @ms,%mb);
  15.  
  16. # 4 possibilities
  17. #   1) called first from the FORUM level, so must create
  18. #      the list of articles, etc.
  19. #   2) called by "pick message" - list of articles exists,
  20. #      so get appropriate one
  21. #   3a) called by "previous" ...
  22. #   3b) called by "next"     ... similar to 2
  23.  
  24. # non-dependent things: must know forum and subject
  25.  if ($in{"forum"} eq "") {
  26.     return "No Forum was selected.";
  27.  }
  28.  local ($forum) = $in{"forum"};
  29.  local ($forumdec)=&WFDecodeDatum($forum);
  30.  if ($in{"subject"} eq "") {
  31.     return "No subject was selected.";
  32.  }
  33.  local ($subject) = $in{"subject"};
  34.  local ($subjectdec)=&WFDecodeDatum($subject);
  35.  
  36. # we do this each time through instead of saving the info
  37. # to allow for re-scanning on each pass, i.e., in case things have changed
  38.  $thedir="ABSWFSPOOL/$forum/$subject";
  39.  opendir(DIR,$thedir)||return "$subjectdec: No such subject could be found!";
  40.  @tmp=readdir(DIR);
  41.  close(DIR);
  42.  for (@tmp) {
  43.   next if $_ eq '.';
  44.   next if $_ eq '..';
  45.   push(@messages,$_);
  46.  }
  47.  if ($in{"sortmethod"} eq "") {
  48.   $in{"sortmethod"}="alphabetic";
  49.  }
  50.  if ($in{"sortmethod"} eq "alphabetic") {
  51.   @messages=sort @messages; }
  52.  elsif ($in{"sortmethod"} eq "mostrecent") {
  53.   @messages=sort WFSubjectstatbymostrecent @messages;
  54.  } 
  55.  
  56.  $thelist="";
  57.  foreach $message (@messages) {
  58.    $mform=join(' <= ',split(';',$message));
  59.    $thelist = $thelist . <<EI
  60.  <li>
  61.   <form method="POST" action="STD_DOCOMMAND">
  62.    <input type="hidden" name="command" value="message">
  63.    <input type="hidden" name="forum" value="$forum">
  64.    <input type="hidden" name="subject" value="$subject">
  65.    <input type="hidden" name="message" value="$message">
  66.    <input type="hidden" name="sortmethod" value="$in{sortmethod}">
  67.    <input type="submit" value="$mform">
  68.   </form>
  69.  </li>
  70. EI
  71.  }
  72.  
  73. # which of the 4 is it? 
  74.  if ($direction eq "this") {
  75.     $message=$in{"message"};
  76.     if ($message eq "None" || $message eq "none" || $message eq "") {
  77.      return "No message found!\n";}
  78.  } elsif ($direction eq "next") {
  79.     if ($#messages < 1) {return "No other messages.\n";}
  80.     @ms=@messages;
  81.     while (@ms && @ms[0] ne $in{"message"}) {shift @ms;};
  82.     if ($#ms < 1) {return "No next message.\n";}
  83.     $message=@ms[1];
  84.  } elsif ($direction eq "prev") {
  85.     if ($#messages < 1) {return "No other messages.\n";}
  86.     @ms=reverse @messages;
  87.     while (@ms && @ms[0] ne $in{"message"}) {shift @ms;};
  88.     if ($#ms < 1) {return "No previous message.\n";}
  89.     $message=@ms[1];
  90.  } else {
  91.   $message=@messages[0];
  92.  }
  93.  
  94.  %mb=&WFGetFile("ABSWFSPOOL/$forum/$subject/$message");
  95.  if (%mb == 0) {return "No such message!\n";}
  96.  if ($mb{"xref"} eq "") {$mb{"xref"}="none"};
  97.  if ($mb{"expiry"} eq "") {$mb{"expiry"}="7 days"};
  98.  
  99.  if ($thelist eq "") {$thelist="<h2>No messages on $subjectdec.</p></h2>";}
  100.  $mform=join(' <= ',split(';',$message));
  101.  $thelist =~ s^value="$mform"^value="$mform (current)"^g;
  102.  
  103.  if ($in{sortmethod} eq "alphabetic") {
  104.   !&WFIncFile("ABSWFHTML/SUBJECT.HTML",
  105.             ENCFORUM,"$forum",
  106.             THEFORUM,"$forumdec",
  107.             ENCSUBJECT,"$subject",
  108.             THESUBJECT,"$subjectdec",
  109.             THEMESSAGE,"$message",
  110.             THEPOSTER,"$mb{poster}",
  111.             THEPEMAIL,"$mb{email}",
  112.             THEPHURL,"$mb{hurl}",
  113.             THEPDT,"$mb{date}",
  114.             THEPXREF,"$mb{xref}",
  115.             THEXPIRE,"$mb{expiry}",
  116.             THEMBODY,"$mb{body}",
  117.             MESSAGELIST,"$thelist",
  118.             SORTYPE,"$in{sortmethod}",
  119.             ASORT,checked,
  120.             MRCSORT,'')
  121.  } else {
  122.   &WFIncFile("ABSWFHTML/SUBJECT.HTML",
  123.             ENCFORUM,"$forum",
  124.             THEFORUM,"$forumdec",
  125.             ENCSUBJECT,"$subject",
  126.             THESUBJECT,"$subjectdec",
  127.             THEMESSAGE,"$message",
  128.             THEPOSTER,"$mb{poster}",
  129.             THEPEMAIL,"$mb{email}",
  130.             THEPHURL,"$mb{hurl}",
  131.             THEPDT,"$mb{date}",
  132.             THEPXREF,"$mb{xref}",
  133.             THEXPIRE,"$mb{expiry}",
  134.             THEMBODY,"$mb{body}",
  135.             MESSAGELIST,"$thelist",
  136.             SORTYPE,"$in{sortmethod}",
  137.             ASORT,'',
  138.             MRCSORT,checked)
  139.  }
  140.  return "";
  141. }
  142.  
  143. sub WFSubjectstatbymostrecent {
  144.  local (@d1) = stat("ABSWFSPOOL/$forum/$subject/$a");
  145.  local (@d2) = stat("ABSWFSPOOL/$forum/$subject/$b");
  146.  $d2[9] <=> $d1[9]; 
  147. }
  148. 1;
  149.